<script src="http://code.jquery.com/jquery-latest.js"></script>

  <link rel="stylesheet" href="/stylesheets/jquery.autocomplete.css" type="text/css" />

  <script type="text/javascript" src="/javascripts/jquery.autocomplete.js"></script>


  <script type="text/javascript" src="/javascripts/prototype.js"></script>
  <script type="text/javascript" src="/javascripts/application.js"></script>

<script type="text/javascript" src="/javascripts/dhtmlgoodies_calendar.js"></script>
<link href="/stylesheets/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css" />

 <h2 align="center" class="ourCompany-hdr"><%=  t('event.new')%></h2>

<% form_for(@event) do |f| %>
  <%= f.error_messages %>


  <table  width="200" aling="center"  border="0" cellspacing="2" cellpadding="2">
	      <tr>
                <th align="left" scope="row"><img src="/images/star.png" width="32" height="32" /></th>
	        <th align="left" nowrap="nowrap"><%=  t('event.even')%>:</th>
	        <td><%= f.text_field :name %></td>

        </tr>
	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.winner')%>:</th>
	        <td><%= f.text_field :winner %></td>
        </tr>
	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.Sdate')%>:</th>
	        <td><%= f.text_field :date_ini,:readonly => true %></td>
                <td>
    <a href="#" onClick="displayCalendar(document.getElementById('event_date_ini'),'yyyy-mm-dd',this)"><img src="/images/calendar.png"></img></a>
                </td>
        </tr>
        	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.Fdate')%>:</th>
	        <td><%= f.text_field :date_fin,:readonly => true %></td>
                 <td>
    <a href="#" onClick="displayCalendar(document.getElementById('event_date_fin'),'yyyy-mm-dd',this)"><img src="/images/calendar.png"></img></a>
  </td>
        </tr>

        	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.pos')%>:</th>
	        <td><%= f.text_field :positions %></td>
        </tr>

        	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.max')%>:</th>
                <td><%= f.text_field :maxamount %></td>
        </tr>


<tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.admin')%>:</th>
                <td><%= f.text_field :administrator_id %></td>
        </tr>
	      <tr>
	        <th align="left" scope="row">&nbsp;</th>
	        <th align="left" nowrap="nowrap"><%=  t('event.categ')%>:</th>
	        <td><input id="category_id" name="category_id"/></td>
                
               
        </tr>
      </table>


  <h1><%=  t('event.competitors')%></h1>

  <%if session[:category_type]=='2'%>
    <% f.fields_for :competitors do |a| %>
    <%= render 'competitor_fields', :f => a %>
  
<%end%>



  <p><%= link_to_add_fields   t('event.add'),f,:competitors %></p>


  <%else%>

      <p class ="competitors">
<label for="event_competitors_attributes_0_name"><%=  t('event.name')%></label><br />
  <input id="event_competitors_attributes_0_name" name="event[competitors_attributes][0][name]" size="30" type="text" /><br />
  <label for="event_competitors_attributes_0_description"<%=  t('event.description')%></label><br />
  <input id="event_competitors_attributes_0_description" name="event[competitors_attributes][0][description]" size="30" type="text" /><br />


</p>

    <p class ="competitors">
<label for="event_competitors_attributes_1_name"><%=  t('event.name')%></label><br />
  <input id="event_competitors_attributes_1_name" name="event[competitors_attributes][1][name]" size="30" type="text" /><br />
  <label for="event_competitors_attributes_1_description"><%=  t('event.description')%></label><br />
  <input id="event_competitors_attributes_1_description" name="event[competitors_attributes][1][description]" size="30" type="text" /><br />

    <input id="event_competitors_attributes_1__destroy" name="event[competitors_attributes][1][_destroy]" type="hidden" />



</p>

  <%end%>



  
 <td><%= image_submit_tag("/images/add_user.png", :title =>   t('event.create'), :border=>0) %></td>
 <td><%= link_to image_tag("/images/back.png", :title =>   t('event.back'), :border=>0), events_path %></td>
<% end %>




  <script>
jQuery.noConflict(); //Necesario porque si no jQuery tiene conflictos con Prototype.js (usado por add_fields y remove_fields)
  jQuery(document).ready(function(){
    var data = <%= @categories.to_json %>;
    jQuery("#category_id").autocomplete(data,{"mustMatch": true});
  });

</script>



